home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-07 | 2.9 KB | 121 lines | [TEXT/MPS ] |
- (*
- CTBChoose type -- Allow the user to configure the tool. The type parameter specifies the
- type of tool to configure ("connection", "terminal", or "file transfer").
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w CTBChoose.p
- link -m ENTRYPOINT -o HyperCommands -rt XCMD=2751 -sn Main=CTBChoose ∂
- CTBChoose.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
-
- © Copyright 1990 by Apple Computer, Inc.
-
- Initial coding 2/90 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S CTBChoose } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure CTBChoose(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- CTBChoose(paramPtr);
- end;
-
- procedure CTBChoose(paramPtr: XCmdPtr);
-
- {$I CTBUtil.inc}
-
- var i: integer;
- tt: ToolType;
- where: Point;
- result: integer;
- s: Str255;
- oldHand, newHand: ConnHandle;
- cHand: ConnHandle;
- tHand: TermHandle;
- ftHand: FTHandle;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(CTBChoose);
- end;
-
- begin
- { Verify the parameter count. }
- if (paramPtr^.paramCount > 1) then Fail('Invalid parameter count');
-
- { Get the tool type. }
- if not ParmPresent(1) then tt := connectionTool
- else tt := GetToolTypeParm(1);
-
- { Make sure the Comm Toolbox is ready and willing. }
- CTBReady;
- { And the tool's been allocated. }
- EnsurePresent(tt);
-
- { Prepare to dialog. }
- SetPt(where,10,40);
-
- { Put up a choose dialog for the appropriate tool. }
- case tt of
- connectionTool:
- begin
- cHand := Globals^^.connHand;
- oldHand := cHand;
- result := CMChoose(cHand,where,nil);
- Globals^^.connHand := cHand;
- newHand := cHand;
- end;
- terminalTool:
- begin
- tHand := Globals^^.termHand;
- oldHand := ConnHandle(tHand);
- result := TMChoose(tHand,where,nil);
- Globals^^.termHand := tHand;
- newHand := ConnHandle(tHand);
- end;
- fileTransferTool:
- begin
- ftHand := Globals^^.FTHand;
- oldHand := ConnHandle(ftHand);
- result := FTChoose(ftHand,where,nil);
- Globals^^.FTHand := ftHand;
- newHand := ConnHandle(ftHand);
- end;
- end;
-
- { If we've changed handles, update the outstanding tool list. }
- if newHand <> oldHand then
- for i := 1 to Globals^^.allToolsSize do
- if Globals^^.allTools[i].cHand = oldHand then Globals^^.allTools[i].cHand := newHand;
-
- { If we ran into problems with the choose, report it. }
- if (result <> chooseOKMinor) and (result <> chooseOKMajor) then
- begin
- case result of
- chooseDisaster: s := 'Choose disaster';
- chooseFailed: s := 'Choose failed';
- chooseAborted: s := 'Choose aborted';
- chooseCancel: s := 'Choose cancel';
- end;
- Fail(s);
- end;
- end;
-
- end.
-